home *** CD-ROM | disk | FTP | other *** search
Wrap
(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=NoFiX Title=Yahoo Movies Description=Yahoo Movies (Quick Picture Grab) Site=http://movies.yahoo.com Language=EN Version= Requires=3.5.0 Comments= License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. | GetInfo=1 [Options] ***************************************************) program YahooPictureGrab; const YMGrabPlot = FALSE; var MovieName: string; procedure AnalyzePage(Address: string); var debugPage: TStringList; strPage, MovieAddr, MovieTitle, MoviePlot, MovieID: string; BeginPos, EndPos: Integer; begin // debugPage:= TStringList.Create; // debugPage.Text := GetPage(Address); // debugPage.SaveToFile('C:\Yahoo1.txt'); strPage:= GetPage(Address); BeginPos:= Pos('Titles Found</b>', strPage); Delete(strPage, 1, BeginPos); if(BeginPos > 0) then begin PickTreeClear; PickTreeAdd('Results for ' + MovieName + ':', ''); BeginPos:= Pos('<a HRef="', strPage); while BeginPos > 0 do begin // Movie Address EndPos:= Pos('">', Copy(strPage, BeginPos, Length(strPage) - BeginPos)) + BeginPos - 1; MovieAddr:= Copy(strPage, BeginPos + 9, EndPos - BeginPos - 9); // Movie Title BeginPos:= EndPos + 2; EndPos:= Pos('</a>', strPage); MovieTitle:= Copy(strPage, BeginPos, EndPos - BeginPos); // Add to listbox PickTreeAdd(MovieTitle, MovieAddr); // Restart the process Delete(strPage, 1, EndPos); BeginPos:= Pos('<a HRef="', strPage); end; if(PickTreeExec(Address)) then begin strPage:= GetPage(Address); BeginPos:= FindBefore('<img src="', strPage, Pos('"Movie Image"', strPage)); if(BeginPos > 0) then begin Delete(strPage, 1, BeginPos + 9); EndPos:= Pos('"', strPage); Address:= Copy(strPage, 1, EndPos - 1); GetPicture(Address); end else ShowMessage('No cover-art was found for :' + MovieName); // Check if we need plot if(GetField(fieldDescription) = '') or (YMGrabPlot = TRUE) then begin BeginPos:= Pos('<font face=arial size=-1><b>' + #13, strPage) + 35; ShowMessage(IntToStr(BeginPos)); Delete(strPage, 1, BeginPos); EndPos:= Pos('<p>', strPage); MoviePlot:= Copy(strPage, 1, EndPos - 3); HTMLDecode(MoviePlot); SetField(fieldDescription, MoviePlot); end; end; end; end; Function FindBefore(wordToFind: string; text: string; sPos: Integer):Integer; var iPos, iFound: Integer; begin Text:= Copy(Text, 1, sPos); iPos:= Pos(wordToFind, Text); iFound:= iPos; while iPos > 0 do begin if(iPos > 0) then Delete(Text, 1, iPos); iPos:= Pos(wordToFind, Text); iFound:= iFound + iPos; end; result:= iFound; end; begin if CheckVersion(3,5,0) then begin MovieName := GetField(fieldOriginalTitle); if MovieName = '' then MovieName := GetField(fieldTranslatedTitle); begin AnalyzePage('http://search.movies.yahoo.com/search/movies/title?p=%5B' + UrlEncode(MovieName) + '%5D+type%3Afeature&intl=us&search=title&s=wt,-$s'); end; end else ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)'); end.